/*
 * @Author: CB
 * @Date: 2023-08-01 09:56:23
 * @Description: 平台工厂管理器
 */
import { PluginFactoryAndroid } from "./PluginFactoryAndroid";
import { PluginFactory } from "./PluginFactory";
import { PluginFactoryIOS } from "./PluginFactoryIOS";
import { PluginFactoryWechat } from "./PluginFactoryWechat";
import { sys } from "cc";

export class PluginFactoryManager {
    private constructor() { }

    private static facotry: PluginFactory = null;

    static factory(): PluginFactory {
        switch (sys.platform) {
            case sys.Platform.ANDROID: {
                if (!this.facotry) {
                    this.facotry = new PluginFactoryAndroid();
                }
                return this.facotry;
                break;
            }
            case sys.Platform.IOS: {
                if (!this.facotry) {
                    this.facotry = new PluginFactoryIOS();
                }
                return this.facotry;
                break;
            }
            case sys.Platform.WECHAT_GAME: {
                if (!this.facotry) {
                    this.facotry = new PluginFactoryWechat();
                }
                return this.facotry;
            }
            default: {
                if (!this.facotry) {
                    this.facotry = new PluginFactory();
                }
                return this.facotry;
            }
        }
    }
}